<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActionView::Helpers::DateHelper</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActionView::Helpers::DateHelper</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/actionpack/lib/action_view/helpers/date_helper_rb.html">
                vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
The Date Helper primarily creates select/option tags for different kinds of
dates and date elements. All of the select-type methods share a number of
common options that are as follows:
</p>
<ul>
<li><tt>:prefix</tt> - overwrites the default prefix of &quot;date&quot; used
for the select names. So specifying &quot;birthday&quot; would give
birthday[month] instead of date[month] if passed to the <a
href="DateHelper.html#M001019">select_month</a> method.

</li>
<li><tt>:include_blank</tt> - set to true if it should be possible to set an
empty date.

</li>
<li><tt>:discard_type</tt> - set to true if you want to discard the type part
of the select name. If set to true, the <a
href="DateHelper.html#M001019">select_month</a> method would use simply
&quot;date&quot; (which can be overwritten using <tt>:prefix</tt>) instead
of &quot;date[month]&quot;.

</li>
</ul>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001009">date_select</a>&nbsp;&nbsp;
      <a href="#M001011">datetime_select</a>&nbsp;&nbsp;
      <a href="#M001006">distance_of_time_in_words</a>&nbsp;&nbsp;
      <a href="#M001008">distance_of_time_in_words_to_now</a>&nbsp;&nbsp;
      <a href="#M001013">select_date</a>&nbsp;&nbsp;
      <a href="#M001012">select_datetime</a>&nbsp;&nbsp;
      <a href="#M001018">select_day</a>&nbsp;&nbsp;
      <a href="#M001017">select_hour</a>&nbsp;&nbsp;
      <a href="#M001016">select_minute</a>&nbsp;&nbsp;
      <a href="#M001019">select_month</a>&nbsp;&nbsp;
      <a href="#M001015">select_second</a>&nbsp;&nbsp;
      <a href="#M001014">select_time</a>&nbsp;&nbsp;
      <a href="#M001020">select_year</a>&nbsp;&nbsp;
      <a href="#M001007">time_ago_in_words</a>&nbsp;&nbsp;
      <a href="#M001010">time_select</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">DEFAULT_PREFIX</td>
          <td>=</td>
          <td class="context-item-value">'date' unless const_defined?('DEFAULT_PREFIX')</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001009" class="method-detail">
        <a name="M001009"></a>

        <div class="method-heading">
          <a href="#M001009" class="method-signature">
          <span class="method-name">date_select</span><span class="method-args">(object_name, method, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of select tags (one for year, month, and day) pre-selected
for accessing a specified date-based attribute (identified by
<tt>method</tt>) on an object assigned to the template (identified by
<tt>object</tt>). It&#8216;s possible to tailor the selects through the
<tt>options</tt> hash, which accepts all the keys that each of the
individual select builders do (like :use_month_numbers for <a
href="DateHelper.html#M001019">select_month</a>) as well as a range of
discard options. The discard options are <tt>:discard_year</tt>,
<tt>:discard_month</tt> and <tt>:discard_day</tt>. Set to true,
they&#8216;ll drop the respective select. Discarding the month select will
also automatically discard the day select. It&#8216;s also possible to
explicitly set the order of the tags using the <tt>:order</tt> option with
an array of symbols <tt>:year</tt>, <tt>:month</tt> and <tt>:day</tt> in
the desired order. Symbols may be omitted and the respective select is not
included.
</p>
<p>
Pass the <tt>:default</tt> option to set the default date. Use a Time
object or a Hash of :year, :month, :day, :hour, :minute, and :second.
</p>
<p>
Passing :disabled =&gt; true as part of the <tt>options</tt> will make
elements inaccessible for change.
</p>
<p>
NOTE: Discarded selects will default to 1. So if no month select is
available, January will be assumed.
</p>
<h4>Examples</h4>
<pre>
  # Generates a date select that when POSTed is stored in the post variable, in the written_on attribute
  date_select(&quot;post&quot;, &quot;written_on&quot;)

  # Generates a date select that when POSTed is stored in the post variable, in the written_on attribute,
  # with the year in the year drop down box starting at 1995.
  date_select(&quot;post&quot;, &quot;written_on&quot;, :start_year =&gt; 1995)

  # Generates a date select that when POSTed is stored in the post variable, in the written_on attribute,
  # with the year in the year drop down box starting at 1995, numbers used for months instead of words,
  # and without a day select box.
  date_select(&quot;post&quot;, &quot;written_on&quot;, :start_year =&gt; 1995, :use_month_numbers =&gt; true,
                                    :discard_day =&gt; true, :include_blank =&gt; true)

  # Generates a date select that when POSTed is stored in the post variable, in the written_on attribute
  # with the fields ordered as day, month, year rather than month, day, year.
  date_select(&quot;post&quot;, &quot;written_on&quot;, :order =&gt; [:day, :month, :year])

  # Generates a date select that when POSTed is stored in the user variable, in the birthday attribute
  # lacking a year field.
  date_select(&quot;user&quot;, &quot;birthday&quot;, :order =&gt; [:month, :day])

  # Generates a date select that when POSTed is stored in the user variable, in the birthday attribute
  # which is initially set to the date 3 days from the current date
  date_select(&quot;post&quot;, &quot;written_on&quot;, :default =&gt; 3.days.from_now)

  # Generates a date select that when POSTed is stored in the credit_card variable, in the bill_due attribute
  # that will have a default day of 20.
  date_select(&quot;credit_card&quot;, &quot;bill_due&quot;, :default =&gt; { :day =&gt; 20 })
</pre>
<p>
The selects are prepared for multi-parameter assignment to an Active Record
object.
</p>
<p>
Note: If the day is not included as an option but the month is, the day
will be set to the 1st to ensure that all month choices are valid.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001009-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001009-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 151</span>
151:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">date_select</span>(<span class="ruby-identifier">object_name</span>, <span class="ruby-identifier">method</span>, <span class="ruby-identifier">options</span> = {})
152:         <span class="ruby-constant">InstanceTag</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">object_name</span>, <span class="ruby-identifier">method</span>, <span class="ruby-keyword kw">self</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:object</span>)).<span class="ruby-identifier">to_date_select_tag</span>(<span class="ruby-identifier">options</span>)
153:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001011" class="method-detail">
        <a name="M001011"></a>

        <div class="method-heading">
          <a href="#M001011" class="method-signature">
          <span class="method-name">datetime_select</span><span class="method-args">(object_name, method, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of select tags (one for year, month, day, hour, and minute)
pre-selected for accessing a specified datetime-based attribute (identified
by <tt>method</tt>) on an object assigned to the template (identified by
<tt>object</tt>). Examples:
</p>
<h4>Examples</h4>
<pre>
  # Generates a datetime select that, when POSTed, will be stored in the post variable in the written_on attribute
  datetime_select(&quot;post&quot;, &quot;written_on&quot;)

  # Generates a datetime select with a year select that starts at 1995 that, when POSTed, will be stored in the
  # post variable in the written_on attribute.
  datetime_select(&quot;post&quot;, &quot;written_on&quot;, :start_year =&gt; 1995)

  # Generates a datetime select with a default value of 3 days from the current time that, when POSTed, will be stored in the
  # trip variable in the departing attribute.
  datetime_select(&quot;trip&quot;, &quot;departing&quot;, :default =&gt; 3.days.from_now)

  # Generates a datetime select that discards the type that, when POSTed, will be stored in the post variable as the written_on
  # attribute.
  datetime_select(&quot;post&quot;, &quot;written_on&quot;, :discard_type =&gt; true)
</pre>
<p>
The selects are prepared for multi-parameter assignment to an Active Record
object.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001011-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001011-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 208</span>
208:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">datetime_select</span>(<span class="ruby-identifier">object_name</span>, <span class="ruby-identifier">method</span>, <span class="ruby-identifier">options</span> = {})
209:         <span class="ruby-constant">InstanceTag</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">object_name</span>, <span class="ruby-identifier">method</span>, <span class="ruby-keyword kw">self</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:object</span>)).<span class="ruby-identifier">to_datetime_select_tag</span>(<span class="ruby-identifier">options</span>)
210:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001006" class="method-detail">
        <a name="M001006"></a>

        <div class="method-heading">
          <a href="#M001006" class="method-signature">
          <span class="method-name">distance_of_time_in_words</span><span class="method-args">(from_time, to_time = 0, include_seconds = false)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Reports the approximate distance in time between two Time or Date objects
or integers as seconds. Set <tt>include_seconds</tt> to true if you want
more detailed approximations when distance &lt; 1 min, 29 secs Distances
are reported base on the following table:
</p>
<p>
0 &lt;-&gt; 29 secs # =&gt; less than a minute 30 secs &lt;-&gt; 1 min, 29
secs # =&gt; 1 minute 1 min, 30 secs &lt;-&gt; 44 mins, 29 secs # =&gt;
[2..44] minutes 44 mins, 30 secs &lt;-&gt; 89 mins, 29 secs # =&gt; about 1
hour 89 mins, 29 secs &lt;-&gt; 23 hrs, 59 mins, 29 secs # =&gt; about
[2..24] hours 23 hrs, 59 mins, 29 secs &lt;-&gt; 47 hrs, 59 mins, 29 secs #
=&gt; 1 day 47 hrs, 59 mins, 29 secs &lt;-&gt; 29 days, 23 hrs, 59 mins, 29
secs # =&gt; [2..29] days 29 days, 23 hrs, 59 mins, 30 secs &lt;-&gt; 59
days, 23 hrs, 59 mins, 29 secs # =&gt; about 1 month 59 days, 23 hrs, 59
mins, 30 secs &lt;-&gt; 1 yr minus 1 sec # =&gt; [2..12] months 1 yr
&lt;-&gt; 2 yrs minus 1 secs # =&gt; about 1 year 2 yrs &lt;-&gt; max time
or date # =&gt; over [2..X] years
</p>
<p>
With include_seconds = true and the difference &lt; 1 minute 29 seconds 0-4
secs # =&gt; less than 5 seconds 5-9 secs # =&gt; less than 10 seconds
10-19 secs # =&gt; less than 20 seconds 20-39 secs # =&gt; half a minute
40-59 secs # =&gt; less than a minute 60-89 secs # =&gt; 1 minute
</p>
<h4>Examples</h4>
<pre>
  from_time = Time.now
  distance_of_time_in_words(from_time, from_time + 50.minutes)        # =&gt; about 1 hour
  distance_of_time_in_words(from_time, 50.minutes.from_now)           # =&gt; about 1 hour
  distance_of_time_in_words(from_time, from_time + 15.seconds)        # =&gt; less than a minute
  distance_of_time_in_words(from_time, from_time + 15.seconds, true)  # =&gt; less than 20 seconds
  distance_of_time_in_words(from_time, 3.years.from_now)              # =&gt; over 3 years
  distance_of_time_in_words(from_time, from_time + 60.hours)          # =&gt; about 3 days
  distance_of_time_in_words(from_time, from_time + 45.seconds, true)  # =&gt; less than a minute
  distance_of_time_in_words(from_time, from_time - 45.seconds, true)  # =&gt; less than a minute
  distance_of_time_in_words(from_time, 76.seconds.from_now)           # =&gt; 1 minute
  distance_of_time_in_words(from_time, from_time + 1.year + 3.days)   # =&gt; about 1 year
  distance_of_time_in_words(from_time, from_time + 4.years + 15.days + 30.minutes + 5.seconds) # =&gt; over 4 years

  to_time = Time.now + 6.years + 19.days
  distance_of_time_in_words(from_time, to_time, true)     # =&gt; over 6 years
  distance_of_time_in_words(to_time, from_time, true)     # =&gt; over 6 years
  distance_of_time_in_words(Time.now, Time.now)           # =&gt; less than a minute
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001006-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001006-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 59</span>
59:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">distance_of_time_in_words</span>(<span class="ruby-identifier">from_time</span>, <span class="ruby-identifier">to_time</span> = <span class="ruby-value">0</span>, <span class="ruby-identifier">include_seconds</span> = <span class="ruby-keyword kw">false</span>)
60:         <span class="ruby-identifier">from_time</span> = <span class="ruby-identifier">from_time</span>.<span class="ruby-identifier">to_time</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">from_time</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_time</span>)
61:         <span class="ruby-identifier">to_time</span> = <span class="ruby-identifier">to_time</span>.<span class="ruby-identifier">to_time</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">to_time</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_time</span>)
62:         <span class="ruby-identifier">distance_in_minutes</span> = (((<span class="ruby-identifier">to_time</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">from_time</span>).<span class="ruby-identifier">abs</span>)<span class="ruby-operator">/</span><span class="ruby-value">60</span>).<span class="ruby-identifier">round</span>
63:         <span class="ruby-identifier">distance_in_seconds</span> = ((<span class="ruby-identifier">to_time</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">from_time</span>).<span class="ruby-identifier">abs</span>).<span class="ruby-identifier">round</span>
64: 
65:         <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">distance_in_minutes</span>
66:           <span class="ruby-keyword kw">when</span> <span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">1</span>
67:             <span class="ruby-keyword kw">return</span> (<span class="ruby-identifier">distance_in_minutes</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">'less than a minute'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'1 minute'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">include_seconds</span>
68:             <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">distance_in_seconds</span>
69:               <span class="ruby-keyword kw">when</span> <span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">4</span>   <span class="ruby-keyword kw">then</span> <span class="ruby-value str">'less than 5 seconds'</span>
70:               <span class="ruby-keyword kw">when</span> <span class="ruby-value">5</span><span class="ruby-operator">..</span><span class="ruby-value">9</span>   <span class="ruby-keyword kw">then</span> <span class="ruby-value str">'less than 10 seconds'</span>
71:               <span class="ruby-keyword kw">when</span> <span class="ruby-value">10</span><span class="ruby-operator">..</span><span class="ruby-value">19</span> <span class="ruby-keyword kw">then</span> <span class="ruby-value str">'less than 20 seconds'</span>
72:               <span class="ruby-keyword kw">when</span> <span class="ruby-value">20</span><span class="ruby-operator">..</span><span class="ruby-value">39</span> <span class="ruby-keyword kw">then</span> <span class="ruby-value str">'half a minute'</span>
73:               <span class="ruby-keyword kw">when</span> <span class="ruby-value">40</span><span class="ruby-operator">..</span><span class="ruby-value">59</span> <span class="ruby-keyword kw">then</span> <span class="ruby-value str">'less than a minute'</span>
74:               <span class="ruby-keyword kw">else</span>             <span class="ruby-value str">'1 minute'</span>
75:             <span class="ruby-keyword kw">end</span>
76: 
77:           <span class="ruby-keyword kw">when</span> <span class="ruby-value">2</span><span class="ruby-operator">..</span><span class="ruby-value">44</span>           <span class="ruby-keyword kw">then</span> <span class="ruby-node">&quot;#{distance_in_minutes} minutes&quot;</span>
78:           <span class="ruby-keyword kw">when</span> <span class="ruby-value">45</span><span class="ruby-operator">..</span><span class="ruby-value">89</span>          <span class="ruby-keyword kw">then</span> <span class="ruby-value str">'about 1 hour'</span>
79:           <span class="ruby-keyword kw">when</span> <span class="ruby-value">90</span><span class="ruby-operator">..</span><span class="ruby-value">1439</span>        <span class="ruby-keyword kw">then</span> <span class="ruby-node">&quot;about #{(distance_in_minutes.to_f / 60.0).round} hours&quot;</span>
80:           <span class="ruby-keyword kw">when</span> <span class="ruby-value">1440</span><span class="ruby-operator">..</span><span class="ruby-value">2879</span>      <span class="ruby-keyword kw">then</span> <span class="ruby-value str">'1 day'</span>
81:           <span class="ruby-keyword kw">when</span> <span class="ruby-value">2880</span><span class="ruby-operator">..</span><span class="ruby-value">43199</span>     <span class="ruby-keyword kw">then</span> <span class="ruby-node">&quot;#{(distance_in_minutes / 1440).round} days&quot;</span>
82:           <span class="ruby-keyword kw">when</span> <span class="ruby-value">43200</span><span class="ruby-operator">..</span><span class="ruby-value">86399</span>    <span class="ruby-keyword kw">then</span> <span class="ruby-value str">'about 1 month'</span>
83:           <span class="ruby-keyword kw">when</span> <span class="ruby-value">86400</span><span class="ruby-operator">..</span><span class="ruby-value">525599</span>   <span class="ruby-keyword kw">then</span> <span class="ruby-node">&quot;#{(distance_in_minutes / 43200).round} months&quot;</span>
84:           <span class="ruby-keyword kw">when</span> <span class="ruby-value">525600</span><span class="ruby-operator">..</span><span class="ruby-value">1051199</span> <span class="ruby-keyword kw">then</span> <span class="ruby-value str">'about 1 year'</span>
85:           <span class="ruby-keyword kw">else</span>                      <span class="ruby-node">&quot;over #{(distance_in_minutes / 525600).round} years&quot;</span>
86:         <span class="ruby-keyword kw">end</span>
87:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001008" class="method-detail">
        <a name="M001008"></a>

        <div class="method-heading">
          <span class="method-name">distance_of_time_in_words_to_now</span><span class="method-args">(from_time, include_seconds = false)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="DateHelper.html#M001007">time_ago_in_words</a>
</p>
        </div>
      </div>

      <div id="method-M001013" class="method-detail">
        <a name="M001013"></a>

        <div class="method-heading">
          <a href="#M001013" class="method-signature">
          <span class="method-name">select_date</span><span class="method-args">(date = Date.today, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of html select-tags (one for year, month, and day)
pre-selected with the <tt>date</tt>. It&#8216;s possible to explicitly set
the order of the tags using the <tt>:order</tt> option with an array of
symbols <tt>:year</tt>, <tt>:month</tt> and <tt>:day</tt> in the desired
order. If you do not supply a Symbol, it will be appended onto the
<tt>:order</tt> passed in.
</p>
<h4>Examples</h4>
<pre>
  my_date = Time.today + 6.days

  # Generates a date select that defaults to the date in my_date (six days after today)
  select_date(my_date)

  # Generates a date select that defaults to today (no specified date)
  select_date()

  # Generates a date select that defaults to the date in my_date (six days after today)
  # with the fields ordered year, month, day rather than month, day, year.
  select_date(my_date, :order =&gt; [:year, :month, :day])

  # Generates a date select that discards the type of the field and defaults to the date in
  # my_date (six days after today)
  select_datetime(my_date_time, :discard_type =&gt; true)

  # Generates a date select that defaults to the datetime in my_date (six days after today)
  # prefixed with 'payday' rather than 'date'
  select_datetime(my_date_time, :prefix =&gt; 'payday')
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001013-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001013-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 274</span>
274:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_date</span>(<span class="ruby-identifier">date</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span>, <span class="ruby-identifier">options</span> = {})
275:         <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:order</span>] <span class="ruby-operator">||=</span> []
276:         [<span class="ruby-identifier">:year</span>, <span class="ruby-identifier">:month</span>, <span class="ruby-identifier">:day</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:order</span>].<span class="ruby-identifier">push</span>(<span class="ruby-identifier">o</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:order</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">o</span>) }
277: 
278:         <span class="ruby-identifier">select_date</span> = <span class="ruby-value str">''</span>
279:         <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:order</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
280:           <span class="ruby-identifier">select_date</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;select_#{o}&quot;</span>, <span class="ruby-identifier">date</span>, <span class="ruby-identifier">options</span>)
281:         <span class="ruby-keyword kw">end</span>
282:         <span class="ruby-identifier">select_date</span>
283:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001012" class="method-detail">
        <a name="M001012"></a>

        <div class="method-heading">
          <a href="#M001012" class="method-signature">
          <span class="method-name">select_datetime</span><span class="method-args">(datetime = Time.now, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of html select-tags (one for year, month, day, hour, and
minute) pre-selected with the <tt>datetime</tt>. It&#8216;s also possible
to explicitly set the order of the tags using the <tt>:order</tt> option
with an array of symbols <tt>:year</tt>, <tt>:month</tt> and <tt>:day</tt>
in the desired order. If you do not supply a Symbol, it will be appended
onto the <tt>:order</tt> passed in. You can also add
<tt>:date_separator</tt> and <tt>:time_separator</tt> keys to the
<tt>options</tt> to control visual display of the elements.
</p>
<h4>Examples</h4>
<pre>
  my_date_time = Time.now + 4.days

  # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
  select_datetime(my_date_time)

  # Generates a datetime select that defaults to today (no specified datetime)
  select_datetime()

  # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
  # with the fields ordered year, month, day rather than month, day, year.
  select_datetime(my_date_time, :order =&gt; [:year, :month, :day])

  # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
  # with a '/' between each date field.
  select_datetime(my_date_time, :date_separator =&gt; '/')

  # Generates a datetime select that discards the type of the field and defaults to the datetime in
  # my_date_time (four days after today)
  select_datetime(my_date_time, :discard_type =&gt; true)

  # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
  # prefixed with 'payday' rather than 'date'
  select_datetime(my_date_time, :prefix =&gt; 'payday')
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001012-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001012-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 243</span>
243:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_datetime</span>(<span class="ruby-identifier">datetime</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>, <span class="ruby-identifier">options</span> = {})
244:         <span class="ruby-identifier">separator</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:datetime_separator</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>
245:         <span class="ruby-identifier">select_date</span>(<span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">options</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">separator</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">select_time</span>(<span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">options</span>)
246:        <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001018" class="method-detail">
        <a name="M001018"></a>

        <div class="method-heading">
          <a href="#M001018" class="method-signature">
          <span class="method-name">select_day</span><span class="method-args">(date, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the days 1 through 31 with
the current day selected. The <tt>date</tt> can also be substituted for a
hour number. Override the field name using the <tt>:field_name</tt> option,
&#8216;day&#8217; by default.
</p>
<h4>Examples</h4>
<pre>
  my_date = Time.today + 2.days

  # Generates a select field for days that defaults to the day for the date in my_date
  select_day(my_time)

  # Generates a select field for days that defaults to the number given
  select_day(5)

  # Generates a select field for days that defaults to the day for the date in my_date
  # that is named 'due' rather than 'day'
  select_day(my_time, :field_name =&gt; 'due')
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001018-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001018-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 432</span>
432:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_day</span>(<span class="ruby-identifier">date</span>, <span class="ruby-identifier">options</span> = {})
433:         <span class="ruby-identifier">val</span> = <span class="ruby-identifier">date</span> <span class="ruby-value">? </span>(<span class="ruby-identifier">date</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Fixnum</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">date</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">day</span>) <span class="ruby-operator">:</span> <span class="ruby-value str">''</span>
434:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_hidden</span>]
435:           <span class="ruby-identifier">hidden_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'day'</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">options</span>)
436:         <span class="ruby-keyword kw">else</span>
437:           <span class="ruby-identifier">day_options</span> = []
438:           <span class="ruby-value">1</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-value">31</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">day</span><span class="ruby-operator">|</span>
439:             <span class="ruby-identifier">day_options</span> <span class="ruby-operator">&lt;&lt;</span> ((<span class="ruby-identifier">val</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">day</span>) <span class="ruby-operator">?</span>
440:               <span class="ruby-node">%(&lt;option value=&quot;#{day}&quot; selected=&quot;selected&quot;&gt;#{day}&lt;/option&gt;\n)</span> <span class="ruby-operator">:</span>
441:               <span class="ruby-node">%(&lt;option value=&quot;#{day}&quot;&gt;#{day}&lt;/option&gt;\n)</span>
442:             )
443:           <span class="ruby-keyword kw">end</span>
444:           <span class="ruby-identifier">select_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'day'</span>, <span class="ruby-identifier">day_options</span>, <span class="ruby-identifier">options</span>)
445:         <span class="ruby-keyword kw">end</span>
446:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001017" class="method-detail">
        <a name="M001017"></a>

        <div class="method-heading">
          <a href="#M001017" class="method-signature">
          <span class="method-name">select_hour</span><span class="method-args">(datetime, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the hours 0 through 23 with
the current hour selected. The <tt>hour</tt> can also be substituted for a
hour number. Override the field name using the <tt>:field_name</tt> option,
&#8216;hour&#8217; by default.
</p>
<h4>Examples</h4>
<pre>
  my_time = Time.now + 6.hours

  # Generates a select field for minutes that defaults to the minutes for the time in my_time
  select_minute(my_time)

  # Generates a select field for minutes that defaults to the number given
  select_minute(14)

  # Generates a select field for minutes that defaults to the minutes for the time in my_time
  # that is named 'stride' rather than 'second'
  select_minute(my_time, :field_name =&gt; 'stride')
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001017-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001017-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 399</span>
399:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_hour</span>(<span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">options</span> = {})
400:         <span class="ruby-identifier">val</span> = <span class="ruby-identifier">datetime</span> <span class="ruby-value">? </span>(<span class="ruby-identifier">datetime</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Fixnum</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">datetime</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">datetime</span>.<span class="ruby-identifier">hour</span>) <span class="ruby-operator">:</span> <span class="ruby-value str">''</span>
401:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_hidden</span>]
402:           <span class="ruby-identifier">hidden_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'hour'</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">options</span>)
403:         <span class="ruby-keyword kw">else</span>
404:           <span class="ruby-identifier">hour_options</span> = []
405:           <span class="ruby-value">0</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-value">23</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">hour</span><span class="ruby-operator">|</span>
406:             <span class="ruby-identifier">hour_options</span> <span class="ruby-operator">&lt;&lt;</span> ((<span class="ruby-identifier">val</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">hour</span>) <span class="ruby-operator">?</span>
407:               <span class="ruby-node">%(&lt;option value=&quot;#{leading_zero_on_single_digits(hour)}&quot; selected=&quot;selected&quot;&gt;#{leading_zero_on_single_digits(hour)}&lt;/option&gt;\n)</span> <span class="ruby-operator">:</span>
408:               <span class="ruby-node">%(&lt;option value=&quot;#{leading_zero_on_single_digits(hour)}&quot;&gt;#{leading_zero_on_single_digits(hour)}&lt;/option&gt;\n)</span>
409:             )
410:           <span class="ruby-keyword kw">end</span>
411:           <span class="ruby-identifier">select_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'hour'</span>, <span class="ruby-identifier">hour_options</span>, <span class="ruby-identifier">options</span>)
412:         <span class="ruby-keyword kw">end</span>
413:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001016" class="method-detail">
        <a name="M001016"></a>

        <div class="method-heading">
          <a href="#M001016" class="method-signature">
          <span class="method-name">select_minute</span><span class="method-args">(datetime, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the minutes 0 through 59 with
the current minute selected. Also can return a select tag with options by
<tt>minute_step</tt> from 0 through 59 with the 00 minute selected The
<tt>minute</tt> can also be substituted for a minute number. Override the
field name using the <tt>:field_name</tt> option, &#8216;minute&#8217; by
default.
</p>
<h4>Examples</h4>
<pre>
  my_time = Time.now + 6.hours

  # Generates a select field for minutes that defaults to the minutes for the time in my_time
  select_minute(my_time)

  # Generates a select field for minutes that defaults to the number given
  select_minute(14)

  # Generates a select field for minutes that defaults to the minutes for the time in my_time
  # that is named 'stride' rather than 'second'
  select_minute(my_time, :field_name =&gt; 'stride')
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001016-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001016-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 366</span>
366:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_minute</span>(<span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">options</span> = {})
367:         <span class="ruby-identifier">val</span> = <span class="ruby-identifier">datetime</span> <span class="ruby-value">? </span>(<span class="ruby-identifier">datetime</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Fixnum</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">datetime</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">datetime</span>.<span class="ruby-identifier">min</span>) <span class="ruby-operator">:</span> <span class="ruby-value str">''</span>
368:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_hidden</span>]
369:           <span class="ruby-identifier">hidden_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'minute'</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">options</span>)
370:         <span class="ruby-keyword kw">else</span>
371:           <span class="ruby-identifier">minute_options</span> = []
372:           <span class="ruby-value">0</span>.<span class="ruby-identifier">step</span>(<span class="ruby-value">59</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:minute_step</span>] <span class="ruby-operator">||</span> <span class="ruby-value">1</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">minute</span><span class="ruby-operator">|</span>
373:             <span class="ruby-identifier">minute_options</span> <span class="ruby-operator">&lt;&lt;</span> ((<span class="ruby-identifier">val</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">minute</span>) <span class="ruby-operator">?</span>
374:               <span class="ruby-node">%(&lt;option value=&quot;#{leading_zero_on_single_digits(minute)}&quot; selected=&quot;selected&quot;&gt;#{leading_zero_on_single_digits(minute)}&lt;/option&gt;\n)</span> <span class="ruby-operator">:</span>
375:               <span class="ruby-node">%(&lt;option value=&quot;#{leading_zero_on_single_digits(minute)}&quot;&gt;#{leading_zero_on_single_digits(minute)}&lt;/option&gt;\n)</span>
376:             )
377:           <span class="ruby-keyword kw">end</span>
378:           <span class="ruby-identifier">select_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'minute'</span>, <span class="ruby-identifier">minute_options</span>, <span class="ruby-identifier">options</span>)
379:          <span class="ruby-keyword kw">end</span>
380:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001019" class="method-detail">
        <a name="M001019"></a>

        <div class="method-heading">
          <a href="#M001019" class="method-signature">
          <span class="method-name">select_month</span><span class="method-args">(date, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the months January through
December with the current month selected. The month names are presented as
keys (what&#8216;s shown to the user) and the month numbers (1-12) are used
as values (what&#8216;s submitted to the server). It&#8216;s also possible
to use month numbers for the presentation instead of names &#8212; set the
<tt>:use_month_numbers</tt> key in <tt>options</tt> to true for this to
happen. If you want both numbers and names, set the
<tt>:add_month_numbers</tt> key in <tt>options</tt> to true. If you would
prefer to show month names as abbreviations, set the
<tt>:use_short_month</tt> key in <tt>options</tt> to true. If you want to
use your own month names, set the <tt>:use_month_names</tt> key in
<tt>options</tt> to an array of 12 month names. Override the field name
using the <tt>:field_name</tt> option, &#8216;month&#8217; by default.
</p>
<h4>Examples</h4>
<pre>
  # Generates a select field for months that defaults to the current month that
  # will use keys like &quot;January&quot;, &quot;March&quot;.
  select_month(Date.today)

  # Generates a select field for months that defaults to the current month that
  # is named &quot;start&quot; rather than &quot;month&quot;
  select_month(Date.today, :field_name =&gt; 'start')

  # Generates a select field for months that defaults to the current month that
  # will use keys like &quot;1&quot;, &quot;3&quot;.
  select_month(Date.today, :use_month_numbers =&gt; true)

  # Generates a select field for months that defaults to the current month that
  # will use keys like &quot;1 - January&quot;, &quot;3 - March&quot;.
  select_month(Date.today, :add_month_numbers =&gt; true)

  # Generates a select field for months that defaults to the current month that
  # will use keys like &quot;Jan&quot;, &quot;Mar&quot;.
  select_month(Date.today, :use_short_month =&gt; true)

  # Generates a select field for months that defaults to the current month that
  # will use keys like &quot;Januar&quot;, &quot;Marts.&quot;
  select_month(Date.today, :use_month_names =&gt; %w(Januar Februar Marts ...))
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001019-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001019-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 482</span>
482:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_month</span>(<span class="ruby-identifier">date</span>, <span class="ruby-identifier">options</span> = {})
483:         <span class="ruby-identifier">val</span> = <span class="ruby-identifier">date</span> <span class="ruby-value">? </span>(<span class="ruby-identifier">date</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Fixnum</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">date</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">month</span>) <span class="ruby-operator">:</span> <span class="ruby-value str">''</span>
484:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_hidden</span>]
485:           <span class="ruby-identifier">hidden_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'month'</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">options</span>)
486:         <span class="ruby-keyword kw">else</span>
487:           <span class="ruby-identifier">month_options</span> = []
488:           <span class="ruby-identifier">month_names</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_month_names</span>] <span class="ruby-operator">||</span> (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_short_month</span>] <span class="ruby-operator">?</span> <span class="ruby-constant">Date</span><span class="ruby-operator">::</span><span class="ruby-constant">ABBR_MONTHNAMES</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Date</span><span class="ruby-operator">::</span><span class="ruby-constant">MONTHNAMES</span>)
489:           <span class="ruby-identifier">month_names</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-keyword kw">nil</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">month_names</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">13</span>
490:           <span class="ruby-value">1</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-value">12</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">month_number</span><span class="ruby-operator">|</span>
491:             <span class="ruby-identifier">month_name</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_month_numbers</span>]
492:               <span class="ruby-identifier">month_number</span>
493:             <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:add_month_numbers</span>]
494:               <span class="ruby-identifier">month_number</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">' - '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">month_names</span>[<span class="ruby-identifier">month_number</span>]
495:             <span class="ruby-keyword kw">else</span>
496:               <span class="ruby-identifier">month_names</span>[<span class="ruby-identifier">month_number</span>]
497:             <span class="ruby-keyword kw">end</span>
498: 
499:             <span class="ruby-identifier">month_options</span> <span class="ruby-operator">&lt;&lt;</span> ((<span class="ruby-identifier">val</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">month_number</span>) <span class="ruby-operator">?</span>
500:               <span class="ruby-node">%(&lt;option value=&quot;#{month_number}&quot; selected=&quot;selected&quot;&gt;#{month_name}&lt;/option&gt;\n)</span> <span class="ruby-operator">:</span>
501:               <span class="ruby-node">%(&lt;option value=&quot;#{month_number}&quot;&gt;#{month_name}&lt;/option&gt;\n)</span>
502:             )
503:           <span class="ruby-keyword kw">end</span>
504:           <span class="ruby-identifier">select_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'month'</span>, <span class="ruby-identifier">month_options</span>, <span class="ruby-identifier">options</span>)
505:         <span class="ruby-keyword kw">end</span>
506:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001015" class="method-detail">
        <a name="M001015"></a>

        <div class="method-heading">
          <a href="#M001015" class="method-signature">
          <span class="method-name">select_second</span><span class="method-args">(datetime, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the seconds 0 through 59 with
the current second selected. The <tt>second</tt> can also be substituted
for a second number. Override the field name using the <tt>:field_name</tt>
option, &#8216;second&#8217; by default.
</p>
<h4>Examples</h4>
<pre>
  my_time = Time.now + 16.minutes

  # Generates a select field for seconds that defaults to the seconds for the time in my_time
  select_second(my_time)

  # Generates a select field for seconds that defaults to the number given
  select_second(33)

  # Generates a select field for seconds that defaults to the seconds for the time in my_time
  # that is named 'interval' rather than 'second'
  select_second(my_time, :field_name =&gt; 'interval')
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001015-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001015-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 332</span>
332:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_second</span>(<span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">options</span> = {})
333:         <span class="ruby-identifier">val</span> = <span class="ruby-identifier">datetime</span> <span class="ruby-value">? </span>(<span class="ruby-identifier">datetime</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Fixnum</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">datetime</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">datetime</span>.<span class="ruby-identifier">sec</span>) <span class="ruby-operator">:</span> <span class="ruby-value str">''</span>
334:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_hidden</span>]
335:           <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:include_seconds</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">hidden_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'second'</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">options</span>) <span class="ruby-operator">:</span> <span class="ruby-value str">''</span>
336:         <span class="ruby-keyword kw">else</span>
337:           <span class="ruby-identifier">second_options</span> = []
338:           <span class="ruby-value">0</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-value">59</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">second</span><span class="ruby-operator">|</span>
339:             <span class="ruby-identifier">second_options</span> <span class="ruby-operator">&lt;&lt;</span> ((<span class="ruby-identifier">val</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">second</span>) <span class="ruby-operator">?</span>
340:               <span class="ruby-node">%(&lt;option value=&quot;#{leading_zero_on_single_digits(second)}&quot; selected=&quot;selected&quot;&gt;#{leading_zero_on_single_digits(second)}&lt;/option&gt;\n)</span> <span class="ruby-operator">:</span>
341:               <span class="ruby-node">%(&lt;option value=&quot;#{leading_zero_on_single_digits(second)}&quot;&gt;#{leading_zero_on_single_digits(second)}&lt;/option&gt;\n)</span>
342:             )
343:           <span class="ruby-keyword kw">end</span>
344:           <span class="ruby-identifier">select_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'second'</span>, <span class="ruby-identifier">second_options</span>, <span class="ruby-identifier">options</span>)
345:         <span class="ruby-keyword kw">end</span>
346:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001014" class="method-detail">
        <a name="M001014"></a>

        <div class="method-heading">
          <a href="#M001014" class="method-signature">
          <span class="method-name">select_time</span><span class="method-args">(datetime = Time.now, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of html select-tags (one for hour and minute) You can set
<tt>:time_separator</tt> key to format the output, and the
<tt>:include_seconds</tt> option to include an input for seconds.
</p>
<h4>Examples</h4>
<pre>
  my_time = Time.now + 5.days + 7.hours + 3.minutes + 14.seconds

  # Generates a time select that defaults to the time in my_time
  select_time(my_time)

  # Generates a time select that defaults to the current time (no specified time)
  select_time()

  # Generates a time select that defaults to the time in my_time,
  # which has fields separated by ':'
  select_time(my_time, :time_separator =&gt; ':')

  # Generates a time select that defaults to the time in my_time,
  # that also includes an input for seconds
  select_time(my_time, :include_seconds =&gt; true)

  # Generates a time select that defaults to the time in my_time, that has fields
  # separated by ':' and includes an input for seconds
  select_time(my_time, :time_separator =&gt; ':', :include_seconds =&gt; true)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001014-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001014-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 310</span>
310:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_time</span>(<span class="ruby-identifier">datetime</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>, <span class="ruby-identifier">options</span> = {})
311:         <span class="ruby-identifier">separator</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:time_separator</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>
312:         <span class="ruby-identifier">select_hour</span>(<span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">options</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">separator</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">select_minute</span>(<span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">options</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:include_seconds</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">separator</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">select_second</span>(<span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">options</span>) <span class="ruby-operator">:</span> <span class="ruby-value str">''</span>)
313:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001020" class="method-detail">
        <a name="M001020"></a>

        <div class="method-heading">
          <a href="#M001020" class="method-signature">
          <span class="method-name">select_year</span><span class="method-args">(date, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a select tag with options for each of the five years on each side
of the current, which is selected. The five year radius can be changed
using the <tt>:start_year</tt> and <tt>:end_year</tt> keys in the
<tt>options</tt>. Both ascending and descending year lists are supported by
making <tt>:start_year</tt> less than or greater than <tt>:end_year</tt>.
The <tt>date</tt> can also be substituted for a year given as a number.
Override the field name using the <tt>:field_name</tt> option,
&#8216;year&#8217; by default.
</p>
<h4>Examples</h4>
<pre>
  # Generates a select field for years that defaults to the current year that
  # has ascending year values
  select_year(Date.today, :start_year =&gt; 1992, :end_year =&gt; 2007)

  # Generates a select field for years that defaults to the current year that
  # is named 'birth' rather than 'year'
  select_year(Date.today, :field_name =&gt; 'birth')

  # Generates a select field for years that defaults to the current year that
  # has descending year values
  select_year(Date.today, :start_year =&gt; 2005, :end_year =&gt; 1900)

  # Generates a select field for years that defaults to the year 2006 that
  # has ascending year values
  select_year(2006, :start_year =&gt; 2000, :end_year =&gt; 2010)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001020-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001020-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 530</span>
530:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_year</span>(<span class="ruby-identifier">date</span>, <span class="ruby-identifier">options</span> = {})
531:         <span class="ruby-identifier">val</span> = <span class="ruby-identifier">date</span> <span class="ruby-value">? </span>(<span class="ruby-identifier">date</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Fixnum</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">date</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">year</span>) <span class="ruby-operator">:</span> <span class="ruby-value str">''</span>
532:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_hidden</span>]
533:           <span class="ruby-identifier">hidden_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'year'</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">options</span>)
534:         <span class="ruby-keyword kw">else</span>
535:           <span class="ruby-identifier">year_options</span> = []
536:           <span class="ruby-identifier">y</span> = <span class="ruby-identifier">date</span> <span class="ruby-value">? </span>(<span class="ruby-identifier">date</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Fixnum</span>) <span class="ruby-operator">?</span> (<span class="ruby-identifier">y</span> = (<span class="ruby-identifier">date</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span>.<span class="ruby-identifier">year</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">date</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">year</span>) <span class="ruby-operator">:</span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">today</span>.<span class="ruby-identifier">year</span>
537: 
538:           <span class="ruby-identifier">start_year</span>, <span class="ruby-identifier">end_year</span> = (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:start_year</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">y</span><span class="ruby-operator">-</span><span class="ruby-value">5</span>), (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:end_year</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">y</span><span class="ruby-operator">+</span><span class="ruby-value">5</span>)
539:           <span class="ruby-identifier">step_val</span> = <span class="ruby-identifier">start_year</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">end_year</span> <span class="ruby-value">? </span><span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">-1</span>
540:           <span class="ruby-identifier">start_year</span>.<span class="ruby-identifier">step</span>(<span class="ruby-identifier">end_year</span>, <span class="ruby-identifier">step_val</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">year</span><span class="ruby-operator">|</span>
541:             <span class="ruby-identifier">year_options</span> <span class="ruby-operator">&lt;&lt;</span> ((<span class="ruby-identifier">val</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">year</span>) <span class="ruby-operator">?</span>
542:               <span class="ruby-node">%(&lt;option value=&quot;#{year}&quot; selected=&quot;selected&quot;&gt;#{year}&lt;/option&gt;\n)</span> <span class="ruby-operator">:</span>
543:               <span class="ruby-node">%(&lt;option value=&quot;#{year}&quot;&gt;#{year}&lt;/option&gt;\n)</span>
544:             )
545:           <span class="ruby-keyword kw">end</span>
546:           <span class="ruby-identifier">select_html</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:field_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'year'</span>, <span class="ruby-identifier">year_options</span>, <span class="ruby-identifier">options</span>)
547:         <span class="ruby-keyword kw">end</span>
548:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001007" class="method-detail">
        <a name="M001007"></a>

        <div class="method-heading">
          <a href="#M001007" class="method-signature">
          <span class="method-name">time_ago_in_words</span><span class="method-args">(from_time, include_seconds = false)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Like <a href="DateHelper.html#M001006">distance_of_time_in_words</a>, but
where <tt>to_time</tt> is fixed to <tt>Time.now</tt>.
</p>
<h4>Examples</h4>
<pre>
  time_ago_in_words(3.minutes.from_now)       # =&gt; 3 minutes
  time_ago_in_words(Time.now - 15.hours)      # =&gt; 15 hours
  time_ago_in_words(Time.now)                 # =&gt; less than a minute

  from_time = Time.now - 3.days - 14.minutes - 25.seconds     # =&gt; 3 days
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001007-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001007-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 97</span>
97:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">time_ago_in_words</span>(<span class="ruby-identifier">from_time</span>, <span class="ruby-identifier">include_seconds</span> = <span class="ruby-keyword kw">false</span>)
98:         <span class="ruby-identifier">distance_of_time_in_words</span>(<span class="ruby-identifier">from_time</span>, <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>, <span class="ruby-identifier">include_seconds</span>)
99:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001010" class="method-detail">
        <a name="M001010"></a>

        <div class="method-heading">
          <a href="#M001010" class="method-signature">
          <span class="method-name">time_select</span><span class="method-args">(object_name, method, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a set of select tags (one for hour, minute and optionally second)
pre-selected for accessing a specified time-based attribute (identified by
<tt>method</tt>) on an object assigned to the template (identified by
<tt>object</tt>). You can include the seconds with
<tt>:include_seconds</tt>.
</p>
<h4>Examples</h4>
<pre>
  # Creates a time select tag that, when POSTed, will be stored in the post variable in the sunrise attribute
  time_select(&quot;post&quot;, &quot;sunrise&quot;)

  # Creates a time select tag that, when POSTed, will be stored in the order variable in the submitted attribute
  time_select(&quot;order&quot;, &quot;submitted&quot;)

  # Creates a time select tag that, when POSTed, will be stored in the mail variable in the sent_at attribute
  time_select(&quot;mail&quot;, &quot;sent_at&quot;)

  # Creates a time select tag with a seconds field that, when POSTed, will be stored in the post variables in
  # the sunrise attribute.
  time_select(&quot;post&quot;, &quot;start_time&quot;, :include_seconds =&gt; true)

  # Creates a time select tag with a seconds field that, when POSTed, will be stored in the entry variables in
  # the submission_time attribute.
  time_select(&quot;entry&quot;, &quot;submission_time&quot;, :include_seconds =&gt; true)

  # You can set the :minute_step to 15 which will give you: 00, 15, 30 and 45.
  time_select 'game', 'game_time', {:minute_step =&gt; 15}
</pre>
<p>
The selects are prepared for multi-parameter assignment to an Active Record
object.
</p>
<p>
Note: If the day is not included as an option but the month is, the day
will be set to the 1st to ensure that all month choices are valid.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001010-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001010-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb, line 184</span>
184:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">time_select</span>(<span class="ruby-identifier">object_name</span>, <span class="ruby-identifier">method</span>, <span class="ruby-identifier">options</span> = {})
185:         <span class="ruby-constant">InstanceTag</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">object_name</span>, <span class="ruby-identifier">method</span>, <span class="ruby-keyword kw">self</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:object</span>)).<span class="ruby-identifier">to_time_select_tag</span>(<span class="ruby-identifier">options</span>)
186:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>